<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>交易所公告信息管理</title>
		<link rel="stylesheet" type="text/css" href="../res/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../res/easyui/themes/color.css">
		<link rel="stylesheet" type="text/css" href="../res/easyui/themes/icon.css">
		<script type="text/javascript" src="../res/js/jquery-1.12.3.min.js"></script>
		<script type="text/javascript" src="../res/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../res/easyui/locale/easyui-lang-zh_CN.js"></script>
		<script src="../res/js/ajaxfileupload.js" type="text/javascript" charset="utf-8"></script>		
		<script type="text/javascript" charset="utf-8" src="../res/ue/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="../res/ue/ueditor.all.min.js"> </script>
		<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
		<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
		<script type="text/javascript" charset="utf-8" src="../res/ue/lang/zh-cn/zh-cn.js"></script>
		<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
		<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
		<style>
			#data_dialog table input[type=text]{
				width: 225px;
			}
			#data_dialog table textarea{
				width: 225px;
				resize: none;
				height: 60px;
			}
			#data_dialog table .ltd{
				text-align: left;
				padding-right: 10px;
			}
			#data_dialog table .rtd{
				text-align: right;
			}
			#data_dialog table td{
				padding: 5px 0;
			}
			
			
			.e_d_file_box {
				float: left;
				height: 30px;
				background: #00EE00;
				width: 140px;
				position: relative;
				cursor: pointer;
			}
			
			.e_d_file_div {
				text-align: center;
				font-size: 15px;
				height: 30px;
				line-height: 30px;
			}
			
			.e_d_file_input {
				width: 140px;
				height: 30px;
				cursor: pointer;
				font-size: 30px;
				outline: medium none;
				position: absolute;
				filter: alpha(opacity=0);
				-moz-opacity: 0;
				opacity: 0;
				left: 0px;
				top: 0px;
			}
		</style>
	</head>
	<body>
		<!--表格的工具栏-->
		<div id="exchange_dg_tb" style="padding:5px;height:auto">
			<div style="margin-bottom:5px;">
				<a href="javascript:openDialog();" class="easyui-linkbutton" iconCls="icon-add"  title="添加" plain="true">添加</a>
				<a href="javascript:updateDialog();" class="easyui-linkbutton" iconCls="icon-edit"  title="修改" plain="true">修改</a>
				<a href="javascript:deleteDialog();" class="easyui-linkbutton" iconCls="icon-remove" title="删除" plain="true">删除</a>
			</div>
			<div>
				<label for="q_sdate">发布时间从:</label><input id="q_sdate" class="easyui-datetimebox" style="width:150px"/>
				<label for="q_edate">到:</label><input id="q_edate" class="easyui-datetimebox" style="width:150px"/>
				<label for="q_indenty">|交易所:</label> 
				<select id="q_eid" class="easyui-combobox" panelHeight="auto" style="width:100px">
					<option value="-1">全部</option>
					<option value="1">南京文交所</option>
					<option value="2">阿商收藏品</option>
					<option value="3">金马甲</option>
					<option value="4">中南</option>
					<option value="5">蓝海</option>
				</select>
				<label for="q_type">|类型:</label> 
				<select id="q_type" class="easyui-combobox" panelHeight="auto" style="width:100px">
					<option value="全部">全部</option>
					<option value="申购">申购</option>
					<option value="入库">入库</option>
					<option value="托管">托管</option>
					<option value="停牌">停牌</option>
					<option value="优惠活动">优惠活动</option>
				</select>
				<a href="javascript:queryData();" class="easyui-linkbutton" iconCls="icon-search">搜索</a>
			</div>
		</div>
		<!--表格的工具栏 结束-->
		<!--表格数据-->
		<table id="news_dg" class="easyui-datagrid" title="交易所信息列表"
			data-options="singleSelect:true, method:'get',url:'json/gg_1.json', fit:true, pagination:true, toolbar:'#exchange_dg_tb'">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th data-options="field:'id',hidden:true">ID</th>
					<th data-options="field:'eid',width:150">交易所</th>
					<th data-options="field:'type',width:100, align:'center'">类型</th>
					<th data-options="field:'title',width:440">标题</th>
					<th data-options="field:'content',width:40, align:'center', formatter:formatterContent">内容</th>
					<th data-options="field:'author',width:100">作者</th>
					<th data-options="field:'pdate',width:130,align:'center'">发布时间</th>
					<th data-options="field:'count',width:100">流量次数</th>
					<th data-options="field:'remark',width:300">预览内容</th>
				</tr>
			</thead>
		</table>
		<!--表格数据 结束-->
		
		
		<!--编辑区域-->
		<div id="data_dialog" class="easyui-dialog" title="头条信息信息对话框" style="height:100%; padding: 10px;"  
		        data-options="iconCls:'icon-save',resizable:false,modal:true, closed:false, maximized:true">  
		    <table border="0" cellspacing="0" cellpadding="0">
		    	<tr>
		    		<td class="rtd">标题：</td>
		    		<td class="ltd"><input type="text" name="title" id="e_d_title" value="" style="width: 500px;" /></td>
		    		<td class="rtd">作者：</td>
		    		<td class="ltd"><input type="text" name="title" id="e_d_author" value="author" /></td>
		    	</tr>
		    	<tr>
		    		<td class="rtd"><label for="e_indenty">交易所:</label></td>
		    		<td class="ltd">
		    			<select id="e_eid" class="easyui-combobox" panelHeight="auto" style="width:100px">
							<option value="1">南京文交所</option>
							<option value="2">阿商收藏品</option>
							<option value="3">金马甲</option>
							<option value="4">中南</option>
							<option value="5">蓝海</option>
						</select>
		    		</td>
		    		<td class="rtd"><label for="e_type">类型:</label></td>
		    		<td>
		    			<select id="e_type" class="easyui-combobox" panelHeight="auto" style="width:100px">
							<option value="申购">申购</option>
							<option value="入库">入库</option>
							<option value="托管">托管</option>
							<option value="停牌">停牌</option>
							<option value="优惠活动">优惠活动</option>
						</select>
		    		</td>
		    	</tr>
		    	<tr>
		    		<td class="rtd">备注信息：</td>
		    		<td><input type="text" name="title" id="e_d_remark" value="" style="width: 500px;" /></td>
		    		<td class="rtd">点击次数：</td>
		    		<td><input type="text" name="title" id="e_d_count" value="525" /></td>
		    	</tr>
		    	<tr>
		    		<td colspan="4" class="rtd">
		    			<input type="button" id="" value="提交" />
		    		</td>
		    	</tr>
		    </table>
			
			<div id="content_box">
				<script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
				<!-- 实例化编辑器 -->
				<script type="text/javascript">
					//实例化编辑器
				    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
				    var MyUEditor = UE.getEditor('editor');
			    	
			    	// 提交信息
			    	function doSubmit(){
			    		var type = $("#type").val();
			    		var title = $("#title").val();
			    		var author = $("#author").val();
			    		var content = $('#xheditor').val();
			    		if("" == title){
			    			alert("请填写标题");
			    			return;
			    		}
			    		if("" == author){
			    			alert("请填作者");
			    			return;
			    		}
			    		if("" == content){
			    			alert("请填内容");
			    			return;
			    		}
			    		$.ajax({
							type:"post",
							url: "<%=request.getContextPath() %>/mgr/ueditor/submit.do",
							async:true,
							data:{"type":type, "title":title, "author":author, "content":content},
							success:function(result){
								alert(result.msg);
								if(result.status == 1){
						    		$("#title").val("");
						    		$('#xheditor').val("");
								}
							}
						});
			    	}
			    	
				</script>
			</div>
		</div>
		<!--编辑区域  结束-->
	</body>
	
	<script type="text/javascript">
		$(function(){
			
		})
		// 点击查询数据
		function searchData(){
		}
		
		// 格式化logo显示
		function formatterContent(value,row,index){
			return "<a href='javascript:updateDialog();'>查看</a>";
		}
		
		// 格式化type
		function formatterType(value,row,index){
			return "头条新闻";
		}
		
		// 打开添加对话框
		function openDialog(){
			$("#e_d_id").val("");
			$("#e_d_title").val("");
			MyUEditor.setContent("");
			
			$("#news_dialog").dialog("open");
		}
		
		
		// 点击修改
		function updateDialog(){
			var row = $("#news_dg").datagrid("getSelected");
			if(row == null){
				alert("请先选中一条要编辑的数据");
				return;
			}
			$("#e_d_id").val(row.id);
			$("#e_d_title").val(row.title);
			$("#e_d_author").val(row.author);
			$("#e_d_remark").val(row.remark);
			MyUEditor.setContent(row.content);
			
			$("#news_dialog").dialog("open");
		}
		
		// 删除一行数据
		function deleteDialog(){
			var row = $("#news_dg").datagrid("getSelected");
			if(row == null){
				alert("请先选中一条要删除的数据");
				return;
			}
			$.messager.confirm('确认对话框','你确定要删除此行数据吗?删除后无法恢复！',function(r){   
			    if (r){   
			        $.ajax({
			        	type:"post",
			        	url:"delete.do",
			        	data:{"id":row.id},
			        	async:true,
			        	success:function(result){
			        		alert(result.msg);
			        		if(result.status == 1){
			        			var index = $("#news_dg").datagrid("getRowIndex", row);
								$("#news_dg").datagrid("deleteRow", index);
							}
			        	}
			        });  
			    }   
			});  
		}
		// 点击提交信息
		function submitInfo(){
			var _id = $("#e_d_id").val();
			var _title = $("#e_d_title").val();
			var _content = MyUEditor.getContent();
			var _remark = $("#e_d_remark").val();
			
			var submitUrl = "add.do";
			if(_id != ""){
				submitUrl = "update.do";
			}
			
			$.ajax({
				type:"post",
				url: submitUrl,
				async:true,
				data:{"id":_id, "title":_title, "content":_content, "remark":_remark},
				success:function(result){
					alert(result.msg);
					$('#news_dialog').dialog('close');
					if(result.status == 1){
						$("#news_dg").datagrid("reload");
					}
				}
			});
		}
	</script>
	
</html>
